﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsBlockReferenceNode : OdGsEntityNode, OdSiEntity
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsBlockReferenceNode(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsBlockReferenceNode_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsBlockReferenceNode obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsBlockReferenceNode()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsBlockReferenceNode(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		HandleRef OdSiEntity.GetCPtr()
		{
			return new HandleRef(this, GlobalsPINVOKE.OdGsBlockReferenceNode_OdSiEntity_GetCPtr(this.swigCPtr.Handle));
		}

		public new static OdGsBlockReferenceNode cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsBlockReferenceNode_cast(OdRxObject.getCPtr(pObj));
			OdGsBlockReferenceNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsBlockReferenceNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsBlockReferenceNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsBlockReferenceNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNode_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNode_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNode_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGsBlockReferenceNode createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsBlockReferenceNode_createObject();
			OdGsBlockReferenceNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsBlockReferenceNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsBlockReferenceNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsBlockReferenceNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsBlockReferenceNode(OdGsBaseModel pModel, OdGiDrawable pDrawable, bool bSetGsNode) : this(GlobalsPINVOKE.new_OdGsBlockReferenceNode__SWIG_0(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pDrawable), bSetGsNode), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsBlockReferenceNode(OdGsBaseModel pModel, OdGiDrawable pDrawable) : this(GlobalsPINVOKE.new_OdGsBlockReferenceNode__SWIG_1(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pDrawable)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isValid()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_isValid(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setValid(bool bSet)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_setValid(this.swigCPtr, bSet);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool excludeFromViewExt()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_excludeFromViewExt(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setExcludeFromViewExt(bool bSet)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_setExcludeFromViewExt(this.swigCPtr, bSet);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool isReference()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_isReference(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool layersChanged(OdGsViewImpl view)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_layersChanged(this.swigCPtr, OdGsViewImpl.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void propagateLayerChanges(OdGsViewImpl view)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_propagateLayerChanges(this.swigCPtr, OdGsViewImpl.getCPtr(view));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void invalidate(OdGsContainerNode pParent, OdGsViewImpl pView, uint mask)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_invalidate(this.swigCPtr, OdGsContainerNode.getCPtr(pParent), OdGsViewImpl.getCPtr(pView), mask);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void destroy()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_destroy(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void destroySubitems()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_destroySubitems(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool select(OdGsBaseVectorizer view, OdSiRecursiveVisitor arg1, OdGsView.SelectionMode mode)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_select(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdSiRecursiveVisitor.getCPtr(arg1), (int)mode);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual uint awareFlags(uint viewportId)
		{
			uint result = GlobalsPINVOKE.OdGsBlockReferenceNode_awareFlags(this.swigCPtr, viewportId);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool awareFlagsAreInvalid(uint viewportId)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_awareFlagsAreInvalid(this.swigCPtr, viewportId);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool isEmpty()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_isEmpty(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGsEntityNode firstEntity()
		{
			OdGsEntityNode result = (OdGsEntityNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNode_firstEntity(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGsEntityNode firstAttrib()
		{
			OdGsEntityNode result = (OdGsEntityNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNode_firstAttrib(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsBlockNode blockNode()
		{
			OdGsBlockNode result = (OdGsBlockNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNode_blockNode(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void clearBlockNode()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_clearBlockNode(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void makeStock()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_makeStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void releaseStock()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_releaseStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void propagateLayerChangesStock()
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_propagateLayerChangesStock(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void updateBlockNode(OdGiDrawable pBlockTableRecord)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_updateBlockNode(this.swigCPtr, OdGiDrawable.getCPtr(pBlockTableRecord));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public IntPtr sharedDefinition()
		{
			IntPtr result = GlobalsPINVOKE.OdGsBlockReferenceNode_sharedDefinition(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isMInsert()
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_isMInsert(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGsBlockReferenceNode create(OdGsBaseModel pModel, OdGiDrawable pDrawable)
		{
			OdGsBlockReferenceNode result = (OdGsBlockReferenceNode)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBlockReferenceNode_create(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pDrawable)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void doDisplay(OdGsDisplayContext ctx)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_doDisplay(this.swigCPtr, ctx);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool doSelect(OdGsBaseVectorizer vect, OdGiDrawable pDrw, OdSiRecursiveVisitor pVisitor, OdGsView.SelectionMode mode)
		{
			bool result = GlobalsPINVOKE.OdGsBlockReferenceNode_doSelect(this.swigCPtr, OdGsBaseVectorizer.getCPtr(vect), OdGiDrawable.getCPtr(pDrw), OdSiRecursiveVisitor.getCPtr(pVisitor), (int)mode);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void spatialQuery(OdGsView view, OdSiRecursiveVisitor pVisitor)
		{
			GlobalsPINVOKE.OdGsBlockReferenceNode_spatialQuery(this.swigCPtr, OdGsView.getCPtr(view), OdSiRecursiveVisitor.getCPtr(pVisitor));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
